package com.eportal.struts.action;

import java.util.ArrayList;
import java.util.List;

import com.eportal.ORM.MpayGroup;
import com.eportal.ORM.ShopView;
import com.eportal.core.BaseAction;
import com.eportal.core.Page;
import com.eportal.service.AdminService;

public class GroupAction extends BaseAction{
	AdminService service;
	private Page page;
	private String start = "0";
	private String limit = "30";
	private boolean success;
	private String message;
	private String mpayModuleId;
	private String mpayModuleName;
	
	
	public AdminService getService() {
		return service;
	}


	public void setService(AdminService service) {
		this.service = service;
	}


	public Page getPage() {
		return page;
	}


	public void setPage(Page page) {
		this.page = page;
	}


	public String getStart() {
		return start;
	}


	public void setStart(String start) {
		this.start = start;
	}


	public String getLimit() {
		return limit;
	}


	public void setLimit(String limit) {
		this.limit = limit;
	}


	public boolean isSuccess() {
		return success;
	}


	public void setSuccess(boolean success) {
		this.success = success;
	}


	public String getMessage() {
		return message;
	}


	public void setMessage(String message) {
		this.message = message;
	}


	public String getMpayModuleId() {
		return mpayModuleId;
	}


	public void setMpayModuleId(String mpayModuleId) {
		this.mpayModuleId = mpayModuleId;
	}


	public String getMpayModuleName() {
		return mpayModuleName;
	}


	public void setMpayModuleName(String mpayModuleName) {
		this.mpayModuleName = mpayModuleName;
	}


	public String getGroupInfo(){
		LOG.info("读取用户组列表数据...");
		int s = Integer.valueOf(start);
		int l = Integer.valueOf(limit);
		String sql = " where '1' = '1' ";
		mpayModuleName = mpayModuleName == null ? "" : mpayModuleName.trim();
		if (!mpayModuleName.equals("")) {
			sql += " and mpay_module_name like '%" + mpayModuleName + "%' ";
		}
		int start = 1;
		if (s != 0)
			start = s / 30 + 1;
		// System.out.println(sql);
		List userList = service.query("from MpayGroup" + sql, start, l);
		page = new Page();
		page.setRoot(userList);
		page.setTotalProperty(service
				.countQuery("select count(*) from MpayGroup" + sql));
		page.setStart(++s);
		page.setLimit(l = l == 0 ? 30 : l);
		return SUCCESS;
	}
}
